﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Media;

namespace WindowsFormsApp3
{
    /// <summary>
    /// 鸟类
    /// </summary>
    class Bird
    {
        /// <summary>
        /// 处理键盘
        /// </summary>
        /// <param name="key"></param>        
        public void KeyDown(String key)
        {
            if (key == "A")
                Rectangle = new Rectangle(Rectangle.X, Rectangle.Y + step, Rectangle.Width, Rectangle.Height);            
            i += 1;
        }

        public Rectangle Rectangle { get; set; }
        //定义鸟的下落速度
        private const int BirdY=15;
        //定义一个参数
        private int i = 1;
        //定义鸟的上升速度
        private const int step = -45;

        public Bird(Rectangle rectangle)
        {
            Rectangle = rectangle;
        }

        //绘制小鸟（填充）
        public void Draw(Graphics g)
        {
            if (i%2==0)
            {
                g.DrawImage(Properties.Resources.birdup, Rectangle);
            }
            
            if (i % 2 != 0)
            {
                g.DrawImage(Properties.Resources.birddown, Rectangle);
            }

        }

        //定义一个下坠函数
        public void birdMove()
        {
            //让小鸟的矩形重新赋予数据值
            this.Rectangle = new Rectangle(this.Rectangle.X, this.Rectangle.Y + BirdY, Rectangle.Width, Rectangle.Height);
        }

    }
}
